package previous.Test_0402;
import java.time.LocalDate;
import java.util.*;
/**
 * Created with Intellij IDEA
 * Description:
 * User: 星辰
 */
public class Bridge_Blue {
    //Excel地址
    public static void main1(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        long n=scan.nextLong();
        StringBuffer stringBuffer=new StringBuffer();
        //模仿十进制
        //下标从0开始要--
        while(n>0) {
            n--;
            //头插
            stringBuffer.insert(0, (char)('A'+n%26));

            n/=26;
        }
        System.out.println(stringBuffer.toString());
        scan.close();
    }

    //日期问题
    public static void main2(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        String string=scan.nextLine();
        String[] split=string.split("/");
        String y=split[0];
        String m=split[1];
        String d=split[2];
        String date1=(Integer.parseInt(y)>60?"19":"20")+y+"-"+m+"-"+d;
        String date2=(Integer.parseInt(d)>60?"19":"20")+d+"-"+y+"-"+m;
        String date3=(Integer.parseInt(d)>60?"19":"20")+d+"-"+m+"-"+y;
        TreeSet<String> dateSet=new TreeSet<String>();
        if(check(date1)) {
            dateSet.add(date1);
        }
        if(check(date2)) {
            dateSet.add(date2);
        }
        if(check(date3)) {
            dateSet.add(date3);
        }
        for(String data:dateSet) {
            System.out.println(data);
        }
        scan.close();
    }
    private static boolean check(String data) {
        try {
            LocalDate.parse(data);
        }catch (Exception e) {
            return false;
        }
        return true;
    }
    //次数差
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        String string=scan.nextLine();
        char[] a=string.toCharArray();
        HashMap<Character, Integer> hashMap=new HashMap<Character, Integer>();
        for(char x:a) {
            hashMap.put(x, hashMap.getOrDefault(x,0)+1);
        }
        int min=Integer.MAX_VALUE;
        int max=Integer.MIN_VALUE;
        for(char x:hashMap.keySet()) {
            int n=hashMap.get(x);
            if(n>max) {
                max=n;
            }
            if(n<min) {
                min=n;
            }
        }
        System.out.println(max-min);
        scan.close();
    }
}
